﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Appsters
{
    public partial class planner : Form
    {
        private bool clicked = false;

        public planner()
        {
            InitializeComponent();

            string docPath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string path = System.IO.Path.Combine(docPath, "Jotter\\Saved Files\\Month Notes");
            System.IO.Directory.CreateDirectory(path);

            calendar.CalendarDimensions = new System.Drawing.Size(2, 2);

            if(nBox.TextLength > 0)
            {
               // Show text in nBox
                //System.IO.StreamReader reader = new System.IO.StreamReader(System.IO.Path.Combine(docPath, "Jotter\\Saved Files\\Month Notes\\MonthlyNotes.txt"));
                //nBox.Text = reader.ReadLine();
                //reader.Close();
            }
        }

        private void exit_Click(object sender, EventArgs e)
        {
            clicked = true;
            Application.Exit();
        }

        private void min_Click(object sender, EventArgs e)
        {
            clicked = true;
            WindowState = FormWindowState.Minimized;
        }

        private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
        {
            //note: why do we not have a "view notes" button somewhere?
            //it's an idea that if a cell has a note associated with it,
            //a textbox somewhere could just get the contents of the note.
            //or the user is directed to the Notes View.

            //if double click go to daily view
            /*if(calendar was double clicked)
            {
                goto daily view
            }*/
        }

        private void toYearly_Click(object sender, EventArgs e)
        {
            yearView yv = new yearView();
            yv.ShowDialog();
            this.Close();
        }

        private void backToProfile_Click(object sender, EventArgs e)
        {
            clicked = true;

            profView p = new profView();
            p.Show();
            this.Hide();
        }

        private void nBox_TextChanged(object sender, EventArgs e)
        {
            if(clicked == true)
            {
                //save to text file
                string docPath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                string monthNotesFolder = System.IO.Path.Combine(docPath, "Jotter\\Saved Files\\Month Notes");
                System.IO.Directory.CreateDirectory(monthNotesFolder);

                string path = System.IO.Path.Combine(monthNotesFolder, "MonthlyNotes.txt");

                System.IO.File.WriteAllText(path, nBox.Text);

                MessageBox.Show("You just saved a text file in your My Documents folder, inside Jotter folder.");
            }
        }

        private void toNotes_Click_1(object sender, EventArgs e)
        {
            clicked = true;

            notes n = new notes();
            n.Show();
            this.Hide();
        }

        private void dailyView_Click(object sender, EventArgs e)
        {
            DailyView d = new DailyView();
            d.Show();
            this.Hide();
        }

 
    }
}
